
{Joins all records of all species from Specimens, Indiv_records_misc, and Indiv_records_std in a single table against lat and long}

{individual records from Specimens - joined on Georeference by georef_ID to get lat and lon}
INSERT INTO `lauren_occur` (`species_ID`,`latdecimal`,`longdecimal`)
SELECT 
	Specimens.species_id,
	Georeference.latdecimal,Georeference.longdecimal
FROM Georeference INNER JOIN Specimens
	ON Georeference.georef_ID = Specimens.georef_ID
	
{individual records from Individ_records_misc - joined on Georeference by georef_ID to get lat and lon}
INSERT INTO `lauren_occur` (`species_ID`,`latdecimal`,`longdecimal`)
SELECT 
	Individ_records_misc.species_id,
	Georeference.latdecimal,Georeference.longdecimal
FROM Georeference INNER JOIN Individ_records_misc
	ON Georeference.georef_ID = Individ_records_misc.georef_ID


{individual records from Individ_records_std - joined on Samples by sample_ID, joined on Georeference by georef_ID to get lat and lon}	
INSERT INTO `lauren_occur` (`species_ID`,`latdecimal`,`longdecimal`)
SELECT
	Individ_records_std.species_id,
	Georeference.latdecimal,Georeference.longdecimal	
FROM Georeference INNER JOIN Samples
	ON Samples.georef_ID=Georeference.georef_ID JOIN Individ_records_std
	ON Individ_records_std.sample_id=Samples.sample_ID


	
	
{double checking georef_ID vs sample_ID in test table `laurens`}	
	
INSERT INTO `laurens` (`std_record_ID`,`species_ID`,`latdecimal`,`longdecimal`)
SELECT
	Individ_records_std.std_record_id,Individ_records_std.species_id,
	Georeference.latdecimal,Georeference.longdecimal	
FROM Georeference INNER JOIN Samples
	ON Samples.georef_ID=Georeference.georef_ID JOIN Individ_records_std
	ON Individ_records_std.sample_id=Samples.sample_ID

	



